package Text22;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    static int N = 1010, total, bound, n;
    static char[][] q = new char[N][N];
    static boolean[][] st = new boolean[N][N];
    static int[] dx = {-1, 0, 1, 0};
    static int[] dy = {0, 1, 0, -1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        in.nextLine();
        for (int i = 0; i < n; i++) {
            q[i] = in.nextLine().toCharArray();
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (!st[i][j] && q[i][j] == '#') {
                    total = 0;
                    bound = 0;
                    bfs(i, j);
                    if (total == bound) {
                        cnt++;
                    }
                }
            }
        }
        System.out.println(cnt);
    }

    private static void bfs(int sx, int sy) {
        Queue<PII> queue = new LinkedList<>();
        queue.offer(new PII(sx, sy));
        st[sx][sy] = true;
        while (!queue.isEmpty()) {
            PII tmp = queue.poll();
            total++;
            boolean flag = false;
            for (int i = 0; i < 4; i++) {
                int x = tmp.x + dx[i];
                int y = tmp.y + dy[i];
                if (x < 0 || x >= n || y < 0 || y >= n) {
                    continue;  // 出界
                }
                if (st[x][y]) {
                    continue;
                }
                if (q[x][y] == '.') {
                    flag = true;
                    continue;
                }
                st[x][y] = true;
                queue.offer(new PII(x, y));
            }
            if (flag) {
                bound++;
            }
        }
    }
}

class PII {
    int x, y;

    public PII(int x, int y) {
        this.x = x;
        this.y = y;
    }
}